package com.rd.student.jike.class2.lihongming.Solution713;

import java.util.Collections;
import java.util.LinkedList;
import java.util.Objects;

/**
 * @Auther:Heinrich
 * @Date:2023/7/14-07-14-16:04
 * @Description:com.rd.student.jike.class2.lihongming.Solution713
 * @version:1.0
 */
public class Question6 {
    public static void main(String[] args) {
        LinkedList StudentList = new LinkedList();
        StudentList.add(new Student("liusan",20,90));
        StudentList.add(new Student("lisi",22,90));
        StudentList.add(new Student("wangwu",20,99));
        StudentList.add(new Student("sunliu",22,100));
        System.out.println(StudentList);
        Collections.sort(StudentList);
        System.out.println(StudentList);
//        Collections.shuffle(StudentList);
//        System.out.println(StudentList);
    }


}
class Student implements Comparable{
    String Name;
    Integer Age;
    Integer Score;

    public Student() {
    }

    public Student(String name, Integer age, Integer score) {
        Name = name;
        Age = age;
        Score = score;
    }

    @Override
    public int compareTo(Object o) {
        Student s = (Student) o;
        if(this.Score>s.Score){
            return -1;
        } else if (this.Score<s.Score) {
            return 1;
        }else{
            if(this.Age>s.Age){
                return 1;
            } else if (this.Age<s.Age) {
                return -1;
            }else{
                return 0;
            }
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(Name, student.Name) && Objects.equals(Age, student.Age) && Objects.equals(Score, student.Score);
    }

    @Override
    public int hashCode() {
        return Objects.hash(Name, Age, Score);
    }

    @Override
    public String toString() {
        return "姓名：" + Name + '\t' +
                ", 年龄：" + Age +'\t'+
                ", 分数：" + Score +
                '\n';
    }
}